//
//  HJXBottomMyInfoView.m
//  Catus
//
//  Created by 晓梦影 on 16/4/18.
//  Copyright © 2016年 黄金星. All rights reserved.
//

#import "HJXBottomMyInfoView.h"
#import "HJXBottomBtn.h"

@implementation HJXBottomMyInfoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    // 添加子控件
    [self setUpSub];
    // 设置按钮
    [self setUpBtn];
    return self;
}

- (void)setUpSub
{
    for (int i = 0; i < 6; ++i) {
        HJXBottomBtn *btn = [HJXBottomBtn buttonWithType:UIButtonTypeCustom];
        btn.tag = i;
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self addSubview:btn];
    }
}

- (void)setUpBtn
{
    for (UIButton *btn in self.subviews) {
        switch (btn.tag) {
            case 0:
                [btn setTitle:@"夜间模式" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"night"] forState:UIControlStateNormal];
                break;
                
            case 1:
                [btn setTitle:@"我关注的人" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"publish"] forState:UIControlStateNormal];
                break;
                
            case 2:
                [btn setTitle:@"我的帖子" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"publish"] forState:UIControlStateNormal];
                break;
                
            case 3:
                [btn setTitle:@"我的收藏" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"publish"] forState:UIControlStateNormal];
                break;
                
            case 4:
                [btn setTitle:@"阅读记录" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"read"] forState:UIControlStateNormal];
                break;
                
            case 5:
                [btn setTitle:@"系统设置" forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
                break;
                
            default:
                break;
        }
    }
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    float btnH = self.frame.size.height / self.subviews.count;
    for (UIButton *btn in self.subviews) {
        btn.frame = CGRectMake(0, btnH * btn.tag, self.frame.size.width, btnH);
    }
}


@end
